package com.hc.sss.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hc.sss.common.ResultMap;
import com.hc.sss.mapper.AdvertisementApplicationMapper;
import com.hc.sss.pojo.AdvertisementApplication;
import com.hc.sss.pojo.Conservator;
import com.hc.sss.service.AdvertisementApplicationService;
@Service
public class AdvertisementApplicationServiceImpl implements AdvertisementApplicationService {

	@Autowired
	AdvertisementApplicationMapper advertisementApplicationMapper;

	//删除广告申请llz
	public int deleteAdvertisementApplication(Integer aaId) {
		return advertisementApplicationMapper.deleteAdvertisementApplication(aaId);
	}

	@Override
	public int insertSelective(AdvertisementApplication advertisementApplication) {
		return advertisementApplicationMapper.insertSelective(advertisementApplication);
	}

	//修改广告申请llz
	public int updateAdvertisementApplication(AdvertisementApplication advertisementApplication) {
		return advertisementApplicationMapper.updateAdvertisementApplication(advertisementApplication);
	}

	//查看广告申请加分页llz
	public ResultMap<AdvertisementApplication> findAdvertisementApplicationList(Map<String, Object> paramMap) {
		ResultMap<AdvertisementApplication> resultMap = new ResultMap<AdvertisementApplication>();
		Integer page = 1;
		Integer limit = 5;
		if (paramMap.get("page") != null && !"".equals(paramMap.get("page"))) {
			page = Integer.valueOf(paramMap.get("page").toString());
		}
		if (paramMap.get("limit") != null && !"".equals(paramMap.get("limit"))) {
			limit = Integer.valueOf(paramMap.get("limit").toString());
		}
		PageHelper.startPage(page, limit);
		List<AdvertisementApplication> list = advertisementApplicationMapper.findAdvertisementApplicationList(paramMap);
		PageInfo<AdvertisementApplication> info = new PageInfo<>(list);
		resultMap.setData(list);
		resultMap.setCount((int)info.getTotal());
		return resultMap;
	}
	

}
